#pragma once
#include <d3d9.h>	
#pragma comment(lib, "d3d9.lib")
#include <d3dx9.h>
#pragma comment(lib, "d3dx9.lib")
#include <dxerr.h>
#pragma comment(lib, "dxerr.lib")
#include <vector>
#include <cmath>
using namespace std;

#ifdef _DEBUG
#ifndef HR

#define HR(x)					\
{								\
	HRESULT hr = x;				\
	if (FAILED(hr))				\
{							\
	DXTRACE_ERR(#x, hr);	\
	DebugBreak();			\
}							\
}
#endif
#else
#ifndef HR
#define HR(x) x;
#endif
#endif


#define DEGTORAD(degree) ((D3DX_PI / 180.0f) * (degree)) // converts from degrees to radians

const int   Unit		= 3;

enum	eObjectType
{
	NO_TYPE,
	AIR_TYPE,
	SOLID_TYPE,
	DOOR_TYPE,
	BUTTON_TYPE,
	BRICK_TYPE,
	WATER_TYPE,
	ENEMY_TYPE,
	PLAYER_TYPE,
	ROCK_TYPE,
	TYPESIZE
};
enum	eMeshType
{
	BRICK,
	PLAYER,
	ENEMY,
	ROCK,
	BUTTON,
	DOOR,
	MESHSIZE
};
enum	eDirection
{
	UP_DIR,
	DOWN_DIR,
	LEFT_DIR,
	RIGHT_DIR,
	SIZE_DIR
};
enum	eStates
{
	IDLE_STATE,
	ATTACK_STATE,
	SIZE_STATE
};

struct	sVertex
{
	D3DXVECTOR3 D3_PositionVector;
	D3DXVECTOR3 D3_NormalVector;
	D3DXVECTOR2 D2_TextureVector;
};
struct	sRotation
{
	float roll;		//X
	float pitch;	//Y
	float yaw;		//Z
	
	sRotation():roll(0),pitch(0),yaw(0){};

	sRotation(float x, float y, float z)
		:pitch(x),
		yaw(y),
		roll(z)
	{};
};
struct	sBOX	// will be used as a 3 dimensional bounding box for objects for collision detection
{
	float top	,bottom;
	float left	,right;
	float front	,back;
	D3DXVECTOR3 center;
	sRotation Rotation;

	sBOX()	// initialize everything to 0 to start with
	{
		top = left = front = bottom = right = back = 0;
	}

	sBOX(D3DXVECTOR3 ObjPosition, sRotation ObjRotation, int Type):center(ObjPosition)
	{
		float Ratio = 5;
		Rotation = sRotation(ObjRotation.pitch,ObjRotation.yaw,ObjRotation.roll);

		if(Type == PLAYER_TYPE)
		{
			//Depth
			back	= ObjPosition.z + Ratio*0.5f;	//5 Thick
			front	= ObjPosition.z - Ratio*0.5f;	//5 Thick
			
			//Width
			left	= ObjPosition.x	- Ratio*0.5f;	//5 Wide	
			right	= ObjPosition.x + Ratio*0.5f;	//5 Wide	

			//Height
			top		= ObjPosition.y + Ratio*0.5f;	//5 Tall
			bottom	= ObjPosition.y - Ratio*0.5f;	//5 Tall

		}

		if(Type == BRICK_TYPE)
		{
			//Depth
			back	= (float)(ObjPosition.z + Ratio);		//10 Thick
			front	= (float)(ObjPosition.z - Ratio);		//10 Thick
			
			//Width
			left	= (float)(ObjPosition.x	- Ratio*1.9);		//20 Wide	
			right	= (float)(ObjPosition.x + Ratio*1.9);		//20 Wide	

			//Height
			top		= (float)(ObjPosition.y + Ratio*1.5f);	//15 Tall
			bottom	= (float)(ObjPosition.y - Ratio*1.5f);	//15 Tall
		}
	}
};
